#include "ScnsTimer.c.h"

#if defined(SCNS_TIMER_ENABLE)&&SCNS_TIMER_ENABLE==1

ScnsStatus scnsBspTimerInit(void)
{
	pit_init();                    
    pit_interrupt_ms(PIT_CH0,10);  
    pit_interrupt_ms(PIT_CH1,4);  
	NVIC_SetPriority(PIT_IRQn,4);
	
    SysTick->LOAD=SysTick_LOAD_RELOAD_Msk;
    SysTick->CTRL=SysTick_CTRL_ENABLE_Msk|SysTick_CTRL_CLKSOURCE_Msk|SysTick_CTRL_TICKINT_Msk;
    NVIC_SetPriority(SysTick_IRQn,0);
    return SCNS_STATUS_OK;
}

ScnsStatus scnsBspTimerPostInit(void)
{
    return SCNS_STATUS_OK;
}

uint64 scnsBspTimerGetSysTickVal(void)
{
    return (SysTick->LOAD-SysTick->VAL);
}

uint64 scnsBspTimerGetSysTickLoad(void)
{
    return (SysTick->LOAD);
}
#endif